import { Tag } from "antd";
import { ColumnsConfig } from "crud";
import { Account } from "./type";

export const columns: ColumnsConfig<Account> = [
  {
    title: "姓名",
    dataIndex: "name",
    key: "name",
    placeholder: "请输入姓名",
    supportSearch: true,
    render: (text) => <a>{text}</a>,
  },
  {
    title: "年龄",
    dataIndex: "age",
    key: "age",
    placeholder: "请输入年龄",
    supportSearch: true,
    sorter: true,
  },
  {
    title: "标签",
    dataIndex: "tag",
    key: "tag",
    supportSearch: true,
    form: {
      type: "Select",
      attrs: {
        // defaultValue:'',
        options: [
          { value: "", label: "--请选择--" },
          { value: "jack", label: "Jack" },
          { value: "lucy", label: "Lucy" },
          { value: "Yiminghe", label: "yiminghe" },
          { value: "disabled", label: "Disabled", disabled: true },
        ],
      },
    },
    render: (text) => <a>{text}</a>,
  },
  {
    title: "标题",
    dataIndex: "address",
    key: "address",
    placeholder: "请输入标题",
    supportSearch: true,
    sorter: true,
  },
  {
    title: "地址",
    dataIndex: "address1",
    key: "address1",
    supportSearch: true,
  },
  {
    title: "标签",
    key: "tags",
    dataIndex: "tags",
    supportSearch: true,
    render: (_, { tags }) => (
      <>
        {tags.map((tag) => {
          let color = tag.length > 5 ? "geekblue" : "green";
          if (tag === "loser") {
            color = "volcano";
          }
          return (
            <Tag color={color} key={tag}>
              {tag}
            </Tag>
          );
        })}
      </>
    ),
  },
];
